<template>
  <div>
    <el-dialog title="修改数值" :visible.sync="open" @open="onOpen" @close="onClose" width="40%">
      <el-row :gutter="15">
        <el-form ref="elForm" :model="formData" :rules="rules" size="mini" label-width="100px">
          <el-col :span="24">
            <el-form-item label="调整猫币" prop="catCoin">
              <el-input-number v-model="formData.catCoin" placeholder="个" controls-position=right>
              </el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="23">
            <el-form-item label="调整猫粮" prop="catFood">
              <el-input-number v-model="formData.catFood" placeholder="个" controls-position=right>
              </el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="23">
            <el-form-item label="调整宠爱值" prop="petValue">
              <el-input-number v-model="formData.petValue" placeholder="个" controls-position=right>
              </el-input-number>
            </el-form-item>
          </el-col>
          <el-col :span="23">
            <el-form-item label="备注信息">
              <el-input v-model="formData.remarks" type="textarea" :autosize="{minRows: 4, maxRows: 3}"
                :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="handelConfirm">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { updateByNumbers } from "@/api/system/catUserAccount";


export default {
  inheritAttrs: false,
  components: {},
  props: [],
  data() {
    return {
      open:false,
      formData: {
        userId:undefined,
        catCoin: undefined,
        catFood: undefined,
        petValue: undefined,
        remarks: undefined,
      },
      rules: {
        remarks: [{
          required: true,
          message: '请填写备注信息',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    init(id){
      this.open = true
      this.formData = {
        userId:id,
        catCoin: undefined,
        catFood: undefined,
        petValue: undefined,
        remarks: undefined,
      }
    },
    onOpen() {},
    onClose() {
      
      this.$refs['elForm'].resetFields()
    },
    close() {
      this.open = false;
    },
    handelConfirm() {
      this.$refs['elForm'].validate(valid => {
        if (valid) {
          updateByNumbers(this.formData).then(response => {
            if (response.code === 200) {
              this.msgSuccess("修改成功");
              this.open = false;
              this.$emit('getList')
              this.close()
            }
          });
        }
      })
    },
  }
}

</script>
<style>
</style>
